<?php 

//应用类

class App{
	//外部调用执行类
	public static function run(){
		//1.始化框架
		self::init();
		//2.设置外部路径
//		self::setUrl();
		//3.自动载入
		spl_autoload_register(array(__CLASS__,'autoload'));
		//4.创建Demo
		self::createDemo();
		//5.实例化控制器
		self::appRun();
	}
	
	//初始化框架 
	private static function init(){
		//设置时区
		date_default_timezone_set('PRC');
		//检测session是否开启
		session_id() || session_start();
	}
	
	//设置外部路径
	private static function setUrl(){
		
	}
	
	//自动载入
	private static function autoload($className){
		require APP_CONTROLLER_PATH."/{$className}.class.php";
	}
	
	//创建Demo
	private static function createDemo(){
		$str=<<<str
<?php
class IndexController extends Controller{
	public function index(){
		header("Content-type:text/html;charset=utf-8");
		echo "<h2>欢迎使用C49超级无敌大框架 </h2>';
	}
}
?>
str;
    $path=APP_CONTROLLER_PATH.'/IndexController.class.php';
	is_file($path) || file_put_contents($path, $str);
	
	}
	
	//实例化控制器
	private static function appRun(){
        //控制器
		$controller=isset($_GET['c'])?ucfirst($_GET['c']):'Index';
		$controller.='Controller';
		//方法
		$action = isset($_GET['a'])?$_GET['a']:'index';
		
		$obj = new $controller;
		$obj -> $action();
		
	}
}


 ?>